class Solution
{
public:
    int numSplits(string s)
    {
        int leftCount[128] = {0};
        int rightCount[128] = {0};
        for (char c : s)
        {
            ++rightCount[c];
        }
        int goodSplitCount = 0;
        for (char c : s)
        {
            ++leftCount[c];
            --rightCount[c];
            int leftType = 0;
            int rightType = 0;
            for (char c = 'a'; c <= 'z'; ++c)
            {
                if (leftCount[c])
                {
                    ++leftType;
                }
                if (rightCount[c])
                {
                    ++rightType;
                }
            }
            if (leftType == rightType)
            {
                ++goodSplitCount;
            }
        }
        return goodSplitCount;
    }
};